package com.ruoyi.common.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 项目/内容分类表 实体类
 */
@Data
@TableName("category") // 指定数据库表名
public class Category implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO) // 主键，自增
    @JsonSerialize(using = ToStringSerializer.class)
    private Integer id;

    @NotBlank(message = "分类名称不能为空")
    @Size(max = 100, message = "分类名称长度不能超过100个字符")
    @TableField("title")
    private String title;


    @NotBlank(message = "分类图标URL不能为空")
    @Size(max = 512, message = "分类图标URL长度不能超过512个字符")
    @TableField("icon")
    private String icon;


    @NotNull(message = "排序字段不能为空")
    @TableField("sort_order")
    private Integer sortOrder = 0;


    @NotNull(message = "是否启用状态不能为空")
    @TableField("is_active")
    private Integer isActive;


    @TableField(value = "created_at", fill = FieldFill.INSERT) // 插入时自动填充
    private LocalDateTime createdAt;

    @TableField("create_by")
    private Integer createBy;

    @TableField("update_by")
    private Integer updateBy;

    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE) // 插入和更新时自动填充
    private LocalDateTime updatedAt;



}